package com.hziee.graduate.ticket.dao;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hziee.graduate.ticket.vo.RoomRecordVO;
import org.apache.ibatis.annotations.Param;
import com.hziee.graduate.ticket.entity.RoomRecord;
import org.apache.ibatis.annotations.Select;


public interface RoomRecordDao extends BaseMapper<RoomRecord> {

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<RoomRecord> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<RoomRecord> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<RoomRecord> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<RoomRecord> entities);

    // 获取近30天的记录
    @Select("SELECT * FROM t_room_record \n" +
            "where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time) and cinema_id = #{cinemaId}\n" +
            "order by done asc,state desc,create_time desc")
    List<RoomRecord> getAllRoomRecordOrderByTime(Long cinemaId);
}

